'aburendercomponents.monkey by Belimoth
Strict
Import abuentity



Interface IRender
	Method Alpha:Float() Property
	Method Alpha:Void(alpha:Float) Property
	Method ZIndex:Int() Property
	Method ZIndex:Void(zIndex:Int) Property
	Method Render:Void()
	'Method StartFlicker:Void(duration:Int = -1, rate:Int = -1, fillColor:Int = -1)					'decide on a default rate
	'Method StopFlicker:Void()
	'Method IsFlickering:Bool()
End



Class RenderComponent Extends EntityComponent<IRender> Implements IRender

Public
	Method Alpha:Float() Property Return _alpha End
	Method Alpha:Void(alpha:Float) Property Self._alpha = alpha End
	Method ZIndex:Int() Property Return _zIndex End
	Method ZIndex:Void(zIndex:Int) Property Self._zIndex = zIndex End
	
	Method Render:Void() Abstract
	
Private
	Field _alpha:Float = 1
	Field _zIndex:Int
End

#Rem
Class ShapeRender Extends RenderComponent
	Method Render:Void()
		DrawRect(owner.X, owner.Y, owner.Width, owner.Height)
	End
End
#End


Class SpriteRender Extends RenderComponent

Public	
	Method Render:Void()
		Local alphaTemp:Float = GetAlpha()
		SetAlpha(_alpha)
		owner.SpriteComponent.Draw(owner.PositionComponent.X, owner.PositionComponent.Y)
		SetAlpha(alphaTemp)
	End
	
	#Rem
	Method StartFlicker:Void(duration:Int = -1, rate:Int = -1, fillColor:Int = -1)
		'TODO
	End
	
	Method StopFlicker:Void()
		'TODO stop flicker effect, if it is in an off cycle then wait until the next on cycle
	End
	
	Method IsFlickering:Bool()
		Return flickering
	End
	#End
Private
	Field flickering:Bool	
End